<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="Cask Data, Inc." name="author" />
<meta content="Copyright © 2017 Cask Data, Inc." name="copyright" />


    <meta name="git_release" content="6.1.1">
    <meta name="git_hash" content="05fbac36f9f7aadeb44f5728cea35136dbc243e5">
    <meta name="git_timestamp" content="2020-02-09 08:22:47 +0800">
    <title>Appendix: HBaseDDLExecutor</title>

    <link rel="stylesheet" href="../_static/cdap-bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-3.3.6/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/bootstrap-sphinx.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/cdap-dynamicscrollspy-4.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/jquery.mCustomScrollbar.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/cdap-jquery.mCustomScrollbar.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/abixTreeList-2.css" type="text/css" />
    <link rel="stylesheet" href="../_static/cdap-bootstrap.css" type="text/css" />

    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '6.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>

    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="Cask Data Application Platform 6.1.1 Documentation" href="../index.html" />
    <link rel="up" title="Appendices" href="index.html" />
    <link rel="next" title="&lt;no title&gt;" href="../security.html" />
    <link rel="prev" title="Appendix: Minimal cdap-site.xml" href="minimal-cdap-site.html" />
    <!-- block extrahead -->
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <!-- block extrahead end -->

</head>
<body role="document">

<!-- block navbar -->
<div id="navbar" class="navbar navbar-inverse navbar-default navbar-fixed-top">
    <div class="container-fluid">
      <div class="row">
        <div class="navbar-header">
          <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
          <a class="navbar-brand" href="../table-of-contents/../../index.html">
            <span><img alt="CDAP logo" src="../_static/cdap_logo.svg"/></span>
          </a>

          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

          <div class="pull-right">
            <div class="dropdown version-dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                role="button" aria-haspopup="true" aria-expanded="false">
                v 6.1.1 <span class="caret"></span>
              </a>
              <ul class="dropdown-menu">
                <li><a href="//docs.cdap.io/cdap/5.1.2/en/index.html">v 5.1.2</a></li>
                <li><a href="//docs.cdap.io/cdap/4.3.4/en/index.html">v 4.3.4</a></li>
              </ul>
            </div>
          </div>
          <form class="navbar-form navbar-right navbar-search" action="../search.html" method="get">
            <div class="form-group">
              <div class="navbar-search-image material-icons"></div>
              <input type="text" name="q" class="form-control" placeholder="  Search" />
            </div>
            <input type="hidden" name="check_keywords" value="yes" />
            <input type="hidden" name="area" value="default" />
          </form>

          <div class="collapse navbar-collapse nav-collapse navbar-right navbar-navigation">
            <ul class="nav navbar-nav"><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../index.html">简介</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link current" href="../table-of-contents/../../guides.html">手册</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../reference-manual/index.html">参考</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../faqs/index.html">帮助</a></li>
            </ul>
          </div>

        </div>
      </div>
    </div>
  </div><!-- block navbar end -->
<!-- block main content -->
<div class="main-container container">
  <div class="row"><div class="col-md-2">
      <div id="sidebar" class="bs-sidenav scrollable-y-outside" role="complementary">
<!-- theme_manual: admin-manual -->
<!-- theme_manual_highlight: guides -->
<!-- sidebar_title_link: ../table-of-contents/../../guides.html -->

  <div role="note" aria-label="manuals links"><h3><a href="../table-of-contents/../../guides.html">Guides</a></h3>

    <ul class="this-page-menu">
      <li class="toctree-l1"><a href="../table-of-contents/../../user-guide/index.html" rel="nofollow">用户手册</a>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../developer-manual/index.html" rel="nofollow">开发手册</a>
      </li>
      <li class="toctree-l1"><b><a href="../table-of-contents/../../admin-manual/index.html" rel="nofollow">管理手册</a></b>
      <nav class="pagenav">
      <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html"> Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cdap-components.html"> CDAP Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="../deployment-architectures.html"> Deployment Architectures</a></li>
<li class="toctree-l1"><a class="reference internal" href="../hadoop-compatibility.html"> Hadoop Compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cdap-hadoop-compatibility.html"> CDAP and Hadoop Compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="../system-requirements.html"> System Requirements</a></li>
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html"> Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../installation/cloudera.html">Cloudera Manager</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/emr.html">Amazon EMR</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/ambari.html">Apache Ambari</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/mapr.html">MapR</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/azure-hdinsight.html">Microsoft Azure HDInsight</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/packages.html">Packages</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation/replication.html">Replication</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../incompatibilities.html"> Incompatibilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="../upgrading/index.html"> Upgrading</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../upgrading/cloudera.html">Cloudera Manager</a></li>
<li class="toctree-l2"><a class="reference internal" href="../upgrading/ambari.html">Apache Ambari</a></li>
<li class="toctree-l2"><a class="reference internal" href="../upgrading/mapr.html">MapR</a></li>
<li class="toctree-l2"><a class="reference internal" href="../upgrading/packages.html">Packages</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../security/index.html"> Security</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../security/perimeter-security.html">Perimeter Security</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/authorization.html">Authorization</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/impersonation.html">Impersonation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/system-services.html">Enabling SSL for System Services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/secure-storage.html">Secure Storage</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../operations/index.html"> Operations</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../operations/logging.html"> Logging and Monitoring</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/metrics.html"> Metrics</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/operations-dashboard.html"> Dashboard and Reports</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/preferences.html"> Preferences and Runtime Arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/scaling-instances.html"> Scaling Instances</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/resource-guarantees.html"> Resource Guarantees in YARN</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/tx-maintenance.html"> Transaction Service Maintenance</a></li>
<li class="toctree-l2"><a class="reference internal" href="../operations/cdap-ui.html"> CDAP UI</a></li>
</ul>
</li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html"> Appendices</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="cdap-site.html"> Appendix: cdap-site.xml</a></li>
<li class="toctree-l2"><a class="reference internal" href="cdap-security.html"> Appendix: cdap-security.xml</a></li>
<li class="toctree-l2"><a class="reference internal" href="minimal-cdap-site.html"> Appendix: Minimal cdap-site.xml</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Appendix: HBaseDDLExecutor</a></li>
</ul>
</li>
</ul>
</nav>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../integrations/index.html" rel="nofollow">集成手册</a>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../examples-manual/index.html" rel="nofollow">最佳实践</a>
      </li>
    </ul>
  </div></div>
    </div><div class="col-md-8 content" id="main-content">
    
  <div class="section" id="appendix-hbaseddlexecutor">
<span id="appendix-hbase-ddl-executor"></span><h1>Appendix: HBaseDDLExecutor<a class="headerlink" href="#appendix-hbaseddlexecutor" title="Permalink to this headline">🔗</a></h1>
<p>For details on replication of CDAP clusters, see <a class="reference internal" href="../installation/replication.html#installation-replication"><span class="std std-ref">CDAP Replication</span></a>.</p>
<p>This document provides a sample implementation of <code class="docutils literal notranslate"><span class="pre">HBaseDDLExecutor</span></code>.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">HBaseDDLExecutorImpl</span></code> class performs the DDL operations on the local and peer cluster
(master and slave).</p>
<div class="section" id="interface">
<h2>Interface<a class="headerlink" href="#interface" title="Permalink to this headline">🔗</a></h2>
<p>Interface of <code class="docutils literal notranslate"><span class="pre">HBaseDDLExecutor</span></code>. Note that this is a <em>Beta</em> feature and subject to change without notice.</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="cm">/**</span>
<span class="cm"> * Interface providing the HBase DDL operations. All methods except {@link #initialize} must</span>
<span class="cm"> * be idempotent in order to allow retry of failed operations.</span>
<span class="cm"> */</span>
<span class="nd">@Beta</span>
<span class="kd">public</span> <span class="kd">interface</span> <span class="nc">HBaseDDLExecutor</span> <span class="kd">extends</span> <span class="n">Closeable</span> <span class="p">{</span>
  <span class="cm">/**</span>
<span class="cm">   * Initialize the {@link HBaseDDLExecutor}.</span>
<span class="cm">   * This method is called once when the executor is created, before any other methods are called.</span>
<span class="cm">   * @param context the context for the executor</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">HBaseDDLExecutorContext</span> <span class="n">context</span><span class="p">);</span>

  <span class="cm">/**</span>
<span class="cm">   * Create the specified namespace if it does not exist.</span>
<span class="cm">   * This method gets called when CDAP attempts to create a new namespace.</span>
<span class="cm">   *</span>
<span class="cm">   * @param name the namespace to create</span>
<span class="cm">   * @return whether the namespace was created</span>
<span class="cm">   * @throws IOException if a remote or network exception occurs</span>
<span class="cm">   */</span>
  <span class="kt">boolean</span> <span class="nf">createNamespaceIfNotExists</span><span class="p">(</span><span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Delete the specified namespace if it exists.</span>
<span class="cm">   * This method is called during namespace deletion process.</span>
<span class="cm">   *</span>
<span class="cm">   * @param name the namespace to delete</span>
<span class="cm">   * @throws IOException if a remote or network exception occurs</span>
<span class="cm">   * @throws IllegalStateException if there are tables in the namespace</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">deleteNamespaceIfExists</span><span class="p">(</span><span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Create the specified table if it does not exist.</span>
<span class="cm">   * This method is called during the creation of an HBase backed dataset (either system or user).</span>
<span class="cm">   *</span>
<span class="cm">   * @param descriptor the descriptor for the table to create</span>
<span class="cm">   * @param splitKeys the initial split keys for the table</span>
<span class="cm">   * @throws IOException if a remote or network exception occurs</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">createTableIfNotExists</span><span class="p">(</span><span class="n">TableDescriptor</span> <span class="n">descriptor</span><span class="p">,</span> <span class="nd">@Nullable</span> <span class="kt">byte</span><span class="o">[][]</span> <span class="n">splitKeys</span><span class="p">)</span>
    <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Enable the specified table if it is disabled.</span>
<span class="cm">   *</span>
<span class="cm">   * @param namespace the namespace of the table to enable</span>
<span class="cm">   * @param name the name of the table to enable</span>
<span class="cm">   * @throws IOException if a remote or network exception occurs</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">enableTableIfDisabled</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Disable the specified table if it is enabled.</span>
<span class="cm">   *</span>
<span class="cm">   * @param namespace the namespace of the table to disable</span>
<span class="cm">   * @param name the name of the table to disable</span>
<span class="cm">   * @throws IOException if a remote or network exception occurs</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">disableTableIfEnabled</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Modify the specified table. This is called when an HBase backed dataset has</span>
<span class="cm">   * its properties modified. In order to modify the HBase table, CDAP first calls</span>
<span class="cm">   * {@code disableTableIfEnabled}, then calls this method, then calls {@code enableTableIfDisabled}.</span>
<span class="cm">   *</span>
<span class="cm">   * @param namespace the namespace of the table to modify</span>
<span class="cm">   * @param name the name of the table to modify</span>
<span class="cm">   * @param descriptor the descriptor for the table</span>
<span class="cm">   * @throws IOException if a remote or network exception occurs</span>
<span class="cm">   * @throws IllegalStateException if the specified table is not disabled</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">modifyTable</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">,</span> <span class="n">TableDescriptor</span> <span class="n">descriptor</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Truncate the specified table. Implementation of this method should disable the table first.</span>
<span class="cm">   * The table must also be re-enabled by implementation at the end of truncate operation.</span>
<span class="cm">   *</span>
<span class="cm">   * @param namespace the namespace of the table to truncate</span>
<span class="cm">   * @param name the name of the table to truncate</span>
<span class="cm">   * @throws IOException if a remote or network exception occurs</span>
<span class="cm">   * @throws IllegalStateException if the specified table is not disabled</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">truncateTable</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Delete the table if it exists. In order to delete the HBase table,</span>
<span class="cm">   * CDAP first calls {@code disableTableIfEnabled}, then calls this method.</span>
<span class="cm">   *</span>
<span class="cm">   * @param namespace the namespace of the table to delete</span>
<span class="cm">   * @param name the table to delete</span>
<span class="cm">   * @throws IOException if a remote or network exception occurs</span>
<span class="cm">   * @throws IllegalStateException if the specified table is not disabled</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">deleteTableIfExists</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Grant permissions on a table or namespace to users or groups.</span>
<span class="cm">   *</span>
<span class="cm">   * @param namespace the namespace of the table</span>
<span class="cm">   * @param table the name of the. If null, then the permissions are applied to the namespace</span>
<span class="cm">   * @param permissions A map from user or group name to the permissions for that user or group, given as a string</span>
<span class="cm">   *                    containing only characters &#39;a&#39;(Admin), &#39;c&#39;(Create), &#39;r&#39;(Read), &#39;w&#39;(Write), and &#39;x&#39;(Execute).</span>
<span class="cm">   *                    Group names must be prefixed with the character &#39;@&#39;.</span>
<span class="cm">   * @throws IOException if anything goes wrong</span>
<span class="cm">   */</span>
  <span class="kt">void</span> <span class="nf">grantPermissions</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="nd">@Nullable</span> <span class="n">String</span> <span class="n">table</span><span class="p">,</span> <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">permissions</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="implementation">
<h2>Implementation<a class="headerlink" href="#implementation" title="Permalink to this headline">🔗</a></h2>
<p>Sample implementation of <code class="docutils literal notranslate"><span class="pre">HBaseDDLExecutor</span></code>, for HBase version 1.0.0-cdh5.5.1:</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="cm">/*</span>
<span class="cm"> * Copyright © 2017 Cask Data, Inc.</span>
<span class="cm"> *</span>
<span class="cm"> * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not</span>
<span class="cm"> * use this file except in compliance with the License. You may obtain a copy of</span>
<span class="cm"> * the License at</span>
<span class="cm"> *</span>
<span class="cm"> * http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="cm"> *</span>
<span class="cm"> * Unless required by applicable law or agreed to in writing, software</span>
<span class="cm"> * distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT</span>
<span class="cm"> * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the</span>
<span class="cm"> * License for the specific language governing permissions and limitations under</span>
<span class="cm"> * the License.</span>
<span class="cm"> */</span>
<span class="kn">package</span> <span class="nn">com.example.hbase.ddlexecutor</span><span class="p">;</span>

<span class="kn">import</span> <span class="nn">io.cdap.cdap.spi.hbase.ColumnFamilyDescriptor</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">io.cdap.cdap.spi.hbase.CoprocessorDescriptor</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">io.cdap.cdap.spi.hbase.HBaseDDLExecutor</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">io.cdap.cdap.spi.hbase.HBaseDDLExecutorContext</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">io.cdap.cdap.spi.hbase.TableDescriptor</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">com.google.common.base.Preconditions</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">com.google.common.base.Stopwatch</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.conf.Configuration</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.fs.Path</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.HColumnDescriptor</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.HConstants</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.HTableDescriptor</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.NamespaceDescriptor</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.NamespaceNotFoundException</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.TableExistsException</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.TableName</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.TableNotDisabledException</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.TableNotEnabledException</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.client.HBaseAdmin</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.io.compress.Compression</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.apache.hadoop.hbase.util.Bytes</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.slf4j.Logger</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">org.slf4j.LoggerFactory</span><span class="p">;</span>

<span class="kn">import</span> <span class="nn">java.io.IOException</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">java.io.StringWriter</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">java.io.UnsupportedEncodingException</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">java.net.URLEncoder</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">java.util.Map</span><span class="p">;</span>
<span class="kn">import</span> <span class="nn">java.util.concurrent.TimeUnit</span><span class="p">;</span>

<span class="cm">/**</span>
<span class="cm"> * Sample implementation of {@link HBaseDDLExecutor} for HBase version 1.0.0-cdh5.5.1</span>
<span class="cm"> */</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">HBaseDDLExecutorImpl</span> <span class="kd">implements</span> <span class="n">HBaseDDLExecutor</span> <span class="p">{</span>
  <span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">Logger</span> <span class="n">LOG</span> <span class="o">=</span> <span class="n">LoggerFactory</span><span class="p">.</span><span class="na">getLogger</span><span class="p">(</span><span class="n">HBaseDDLExecutorImpl</span><span class="p">.</span><span class="na">class</span><span class="p">);</span>
  <span class="kd">private</span> <span class="n">HBaseAdmin</span> <span class="n">admin</span><span class="p">;</span>
  <span class="kd">private</span> <span class="n">HBaseAdmin</span> <span class="n">peerAdmin</span><span class="p">;</span>

  <span class="cm">/**</span>
<span class="cm">   * Encode a HBase entity name to ASCII encoding using {@link URLEncoder}.</span>
<span class="cm">   *</span>
<span class="cm">   * @param entityName entity string to be encoded</span>
<span class="cm">   * @return encoded string</span>
<span class="cm">   */</span>
  <span class="kd">private</span> <span class="n">String</span> <span class="nf">encodeHBaseEntity</span><span class="p">(</span><span class="n">String</span> <span class="n">entityName</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">try</span> <span class="p">{</span>
      <span class="k">return</span> <span class="n">URLEncoder</span><span class="p">.</span><span class="na">encode</span><span class="p">(</span><span class="n">entityName</span><span class="p">,</span> <span class="s">&quot;ASCII&quot;</span><span class="p">);</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">UnsupportedEncodingException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
      <span class="c1">// this can never happen - we know that ASCII is a supported character set!</span>
      <span class="k">throw</span> <span class="k">new</span> <span class="n">RuntimeException</span><span class="p">(</span><span class="n">e</span><span class="p">);</span>
    <span class="p">}</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">HBaseDDLExecutorContext</span> <span class="n">context</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">LOG</span><span class="p">.</span><span class="na">info</span><span class="p">(</span><span class="s">&quot;Initializing executor with properties {}&quot;</span><span class="p">,</span> <span class="n">context</span><span class="p">.</span><span class="na">getProperties</span><span class="p">());</span>
    <span class="k">try</span> <span class="p">{</span>
      <span class="n">Configuration</span> <span class="n">conf</span> <span class="o">=</span> <span class="n">context</span><span class="p">.</span><span class="na">getConfiguration</span><span class="p">();</span>
      <span class="k">this</span><span class="p">.</span><span class="na">admin</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HBaseAdmin</span><span class="p">(</span><span class="n">conf</span><span class="p">);</span>

      <span class="n">Configuration</span> <span class="n">peerConf</span> <span class="o">=</span> <span class="n">generatePeerConfig</span><span class="p">(</span><span class="n">context</span><span class="p">);</span>
      <span class="k">this</span><span class="p">.</span><span class="na">peerAdmin</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HBaseAdmin</span><span class="p">(</span><span class="n">peerConf</span><span class="p">);</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">IOException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
      <span class="k">throw</span> <span class="k">new</span> <span class="n">RuntimeException</span><span class="p">(</span><span class="s">&quot;Failed to create the HBaseAdmin&quot;</span><span class="p">,</span> <span class="n">e</span><span class="p">);</span>
    <span class="p">}</span>
  <span class="p">}</span>

  <span class="kd">private</span> <span class="kt">boolean</span> <span class="nf">hasNamespace</span><span class="p">(</span><span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">admin</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;HBaseAdmin should not be null&quot;</span><span class="p">);</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">name</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Namespace should not be null.&quot;</span><span class="p">);</span>
    <span class="k">try</span> <span class="p">{</span>
      <span class="n">admin</span><span class="p">.</span><span class="na">getNamespaceDescriptor</span><span class="p">(</span><span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">));</span>
      <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">NamespaceNotFoundException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
      <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
    <span class="p">}</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">createNamespaceIfNotExists</span><span class="p">(</span><span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">name</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Namespace should not be null.&quot;</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">hasNamespace</span><span class="p">(</span><span class="n">name</span><span class="p">))</span> <span class="p">{</span>
      <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="n">NamespaceDescriptor</span> <span class="n">namespaceDescriptor</span> <span class="o">=</span>
      <span class="n">NamespaceDescriptor</span><span class="p">.</span><span class="na">create</span><span class="p">(</span><span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">)).</span><span class="na">build</span><span class="p">();</span>
    <span class="n">admin</span><span class="p">.</span><span class="na">createNamespace</span><span class="p">(</span><span class="n">namespaceDescriptor</span><span class="p">);</span>
    <span class="n">peerAdmin</span><span class="p">.</span><span class="na">createNamespace</span><span class="p">(</span><span class="n">namespaceDescriptor</span><span class="p">);</span>
    <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">deleteNamespaceIfExists</span><span class="p">(</span><span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">name</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Namespace should not be null.&quot;</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">hasNamespace</span><span class="p">(</span><span class="n">name</span><span class="p">))</span> <span class="p">{</span>
      <span class="n">admin</span><span class="p">.</span><span class="na">deleteNamespace</span><span class="p">(</span><span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">));</span>
      <span class="n">peerAdmin</span><span class="p">.</span><span class="na">deleteNamespace</span><span class="p">(</span><span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">));</span>
    <span class="p">}</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">createTableIfNotExists</span><span class="p">(</span><span class="n">TableDescriptor</span> <span class="n">descriptor</span><span class="p">,</span> <span class="kt">byte</span><span class="o">[][]</span> <span class="n">splitKeys</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">createTableIfNotExists</span><span class="p">(</span><span class="n">getHTableDescriptor</span><span class="p">(</span><span class="n">descriptor</span><span class="p">),</span> <span class="n">splitKeys</span><span class="p">);</span>
  <span class="p">}</span>

  <span class="kd">private</span> <span class="kt">void</span> <span class="nf">createTableIfNotExists</span><span class="p">(</span><span class="n">HTableDescriptor</span> <span class="n">htd</span><span class="p">,</span> <span class="kt">byte</span><span class="o">[][]</span> <span class="n">splitKeys</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">admin</span><span class="p">.</span><span class="na">tableExists</span><span class="p">(</span><span class="n">htd</span><span class="p">.</span><span class="na">getName</span><span class="p">()))</span> <span class="p">{</span>
      <span class="k">return</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="k">try</span> <span class="p">{</span>
      <span class="n">admin</span><span class="p">.</span><span class="na">createTable</span><span class="p">(</span><span class="n">htd</span><span class="p">,</span> <span class="n">splitKeys</span><span class="p">);</span>
      <span class="n">peerAdmin</span><span class="p">.</span><span class="na">createTable</span><span class="p">(</span><span class="n">htd</span><span class="p">,</span> <span class="n">splitKeys</span><span class="p">);</span>
      <span class="n">LOG</span><span class="p">.</span><span class="na">info</span><span class="p">(</span><span class="s">&quot;Table created &#39;{}&#39;&quot;</span><span class="p">,</span> <span class="n">Bytes</span><span class="p">.</span><span class="na">toString</span><span class="p">(</span><span class="n">htd</span><span class="p">.</span><span class="na">getName</span><span class="p">()));</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">TableExistsException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
      <span class="c1">// table may exist because someone else is creating it at the same</span>
      <span class="c1">// time. But it may not be available yet, and opening it might fail.</span>
      <span class="n">LOG</span><span class="p">.</span><span class="na">info</span><span class="p">(</span><span class="s">&quot;Table &#39;{}&#39; already exists.&quot;</span><span class="p">,</span> <span class="n">Bytes</span><span class="p">.</span><span class="na">toString</span><span class="p">(</span><span class="n">htd</span><span class="p">.</span><span class="na">getName</span><span class="p">()),</span> <span class="n">e</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="c1">// Wait for table to materialize</span>
    <span class="k">try</span> <span class="p">{</span>
      <span class="n">Stopwatch</span> <span class="n">stopwatch</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Stopwatch</span><span class="p">();</span>
      <span class="n">stopwatch</span><span class="p">.</span><span class="na">start</span><span class="p">();</span>
      <span class="kt">long</span> <span class="n">sleepTime</span> <span class="o">=</span> <span class="n">TimeUnit</span><span class="p">.</span><span class="na">MILLISECONDS</span><span class="p">.</span><span class="na">toNanos</span><span class="p">(</span><span class="mi">5000L</span><span class="p">)</span> <span class="o">/</span> <span class="mi">10</span><span class="p">;</span>
      <span class="n">sleepTime</span> <span class="o">=</span> <span class="n">sleepTime</span> <span class="o">&lt;=</span> <span class="mi">0</span> <span class="o">?</span> <span class="mi">1</span> <span class="p">:</span> <span class="n">sleepTime</span><span class="p">;</span>
      <span class="k">do</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">admin</span><span class="p">.</span><span class="na">tableExists</span><span class="p">(</span><span class="n">htd</span><span class="p">.</span><span class="na">getName</span><span class="p">()))</span> <span class="p">{</span>
          <span class="n">LOG</span><span class="p">.</span><span class="na">debug</span><span class="p">(</span><span class="s">&quot;Table &#39;{}&#39; exists now. Assuming that another process concurrently created it.&quot;</span><span class="p">,</span>
                    <span class="n">Bytes</span><span class="p">.</span><span class="na">toString</span><span class="p">(</span><span class="n">htd</span><span class="p">.</span><span class="na">getName</span><span class="p">()));</span>
          <span class="k">return</span><span class="p">;</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
          <span class="n">TimeUnit</span><span class="p">.</span><span class="na">NANOSECONDS</span><span class="p">.</span><span class="na">sleep</span><span class="p">(</span><span class="n">sleepTime</span><span class="p">);</span>
        <span class="p">}</span>
      <span class="p">}</span> <span class="k">while</span> <span class="p">(</span><span class="n">stopwatch</span><span class="p">.</span><span class="na">elapsedTime</span><span class="p">(</span><span class="n">TimeUnit</span><span class="p">.</span><span class="na">MILLISECONDS</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">5000L</span><span class="p">);</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">InterruptedException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">LOG</span><span class="p">.</span><span class="na">warn</span><span class="p">(</span><span class="s">&quot;Sleeping thread interrupted.&quot;</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="n">LOG</span><span class="p">.</span><span class="na">error</span><span class="p">(</span><span class="s">&quot;Table &#39;{}&#39; does not exist after waiting {} ms. Giving up.&quot;</span><span class="p">,</span> <span class="n">Bytes</span><span class="p">.</span><span class="na">toString</span><span class="p">(</span><span class="n">htd</span><span class="p">.</span><span class="na">getName</span><span class="p">()),</span> <span class="mi">5000L</span><span class="p">);</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">enableTableIfDisabled</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">namespace</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Namespace should not be null&quot;</span><span class="p">);</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">name</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Table name should not be null.&quot;</span><span class="p">);</span>

    <span class="k">try</span> <span class="p">{</span>
      <span class="n">admin</span><span class="p">.</span><span class="na">enableTable</span><span class="p">(</span><span class="n">TableName</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">)));</span>
      <span class="n">peerAdmin</span><span class="p">.</span><span class="na">enableTable</span><span class="p">(</span><span class="n">TableName</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">)));</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">TableNotDisabledException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">LOG</span><span class="p">.</span><span class="na">debug</span><span class="p">(</span><span class="s">&quot;Attempt to enable already enabled table {} in the namespace {}.&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">namespace</span><span class="p">);</span>
    <span class="p">}</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">disableTableIfEnabled</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">namespace</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Namespace should not be null&quot;</span><span class="p">);</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">name</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Table name should not be null.&quot;</span><span class="p">);</span>

    <span class="k">try</span> <span class="p">{</span>
      <span class="n">admin</span><span class="p">.</span><span class="na">disableTable</span><span class="p">(</span><span class="n">TableName</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">)));</span>
      <span class="n">peerAdmin</span><span class="p">.</span><span class="na">disableTable</span><span class="p">(</span><span class="n">TableName</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">)));</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">TableNotEnabledException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">LOG</span><span class="p">.</span><span class="na">debug</span><span class="p">(</span><span class="s">&quot;Attempt to disable already disabled table {} in the namespace {}.&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">namespace</span><span class="p">);</span>
    <span class="p">}</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">modifyTable</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">,</span> <span class="n">TableDescriptor</span> <span class="n">descriptor</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">namespace</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Namespace should not be null&quot;</span><span class="p">);</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">name</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Table name should not be null.&quot;</span><span class="p">);</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">descriptor</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Descriptor should not be null.&quot;</span><span class="p">);</span>

    <span class="n">HTableDescriptor</span> <span class="n">htd</span> <span class="o">=</span> <span class="n">getHTableDescriptor</span><span class="p">(</span><span class="n">descriptor</span><span class="p">);</span>
    <span class="n">admin</span><span class="p">.</span><span class="na">modifyTable</span><span class="p">(</span><span class="n">htd</span><span class="p">.</span><span class="na">getTableName</span><span class="p">(),</span> <span class="n">htd</span><span class="p">);</span>
    <span class="n">peerAdmin</span><span class="p">.</span><span class="na">modifyTable</span><span class="p">(</span><span class="n">htd</span><span class="p">.</span><span class="na">getTableName</span><span class="p">(),</span> <span class="n">htd</span><span class="p">);</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">truncateTable</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">namespace</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Namespace should not be null&quot;</span><span class="p">);</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">name</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Table name should not be null.&quot;</span><span class="p">);</span>

    <span class="n">HTableDescriptor</span> <span class="n">descriptor</span> <span class="o">=</span> <span class="n">admin</span><span class="p">.</span><span class="na">getTableDescriptor</span><span class="p">(</span><span class="n">TableName</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">)));</span>
    <span class="n">disableTableIfEnabled</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">name</span><span class="p">);</span>
    <span class="n">deleteTableIfExists</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">name</span><span class="p">);</span>
    <span class="n">createTableIfNotExists</span><span class="p">(</span><span class="n">descriptor</span><span class="p">,</span> <span class="kc">null</span><span class="p">);</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">deleteTableIfExists</span><span class="p">(</span><span class="n">String</span> <span class="n">namespace</span><span class="p">,</span> <span class="n">String</span> <span class="n">name</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">namespace</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Namespace should not be null&quot;</span><span class="p">);</span>
    <span class="n">Preconditions</span><span class="p">.</span><span class="na">checkArgument</span><span class="p">(</span><span class="n">name</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">,</span> <span class="s">&quot;Table name should not be null.&quot;</span><span class="p">);</span>

    <span class="n">admin</span><span class="p">.</span><span class="na">deleteTable</span><span class="p">(</span><span class="n">TableName</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">)));</span>
    <span class="n">peerAdmin</span><span class="p">.</span><span class="na">deleteTable</span><span class="p">(</span><span class="n">TableName</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">namespace</span><span class="p">,</span> <span class="n">encodeHBaseEntity</span><span class="p">(</span><span class="n">name</span><span class="p">)));</span>
  <span class="p">}</span>

  <span class="nd">@Override</span>
  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">grantPermissions</span><span class="p">(</span><span class="n">String</span> <span class="n">s</span><span class="p">,</span> <span class="n">String</span> <span class="n">s1</span><span class="p">,</span> <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">map</span><span class="p">)</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="c1">// no-op</span>
  <span class="p">}</span>

  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">close</span><span class="p">()</span> <span class="kd">throws</span> <span class="n">IOException</span> <span class="p">{</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">admin</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">admin</span><span class="p">.</span><span class="na">close</span><span class="p">();</span>
    <span class="p">}</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">peerAdmin</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">peerAdmin</span><span class="p">.</span><span class="na">close</span><span class="p">();</span>
    <span class="p">}</span>
  <span class="p">}</span>

  <span class="cm">/**</span>
<span class="cm">   * Converts the {@link ColumnFamilyDescriptor} to the {@link HColumnDescriptor} for admin operations.</span>
<span class="cm">   * @param ns the namespace for the table</span>
<span class="cm">   * @param tableName the name of the table</span>
<span class="cm">   * @param descriptor descriptor of the column family</span>
<span class="cm">   * @return the instance of HColumnDescriptor</span>
<span class="cm">   */</span>
  <span class="kd">private</span> <span class="kd">static</span> <span class="n">HColumnDescriptor</span> <span class="nf">getHColumnDesciptor</span><span class="p">(</span><span class="n">String</span> <span class="n">ns</span><span class="p">,</span> <span class="n">String</span> <span class="n">tableName</span><span class="p">,</span>
                                                       <span class="n">ColumnFamilyDescriptor</span> <span class="n">descriptor</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">HColumnDescriptor</span> <span class="n">hFamily</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HColumnDescriptor</span><span class="p">(</span><span class="n">descriptor</span><span class="p">.</span><span class="na">getName</span><span class="p">());</span>
    <span class="n">hFamily</span><span class="p">.</span><span class="na">setMaxVersions</span><span class="p">(</span><span class="n">descriptor</span><span class="p">.</span><span class="na">getMaxVersions</span><span class="p">());</span>
    <span class="n">hFamily</span><span class="p">.</span><span class="na">setCompressionType</span><span class="p">(</span><span class="n">Compression</span><span class="p">.</span><span class="na">Algorithm</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">descriptor</span><span class="p">.</span><span class="na">getCompressionType</span><span class="p">().</span><span class="na">name</span><span class="p">()));</span>
    <span class="n">hFamily</span><span class="p">.</span><span class="na">setBloomFilterType</span><span class="p">(</span><span class="n">org</span><span class="p">.</span><span class="na">apache</span><span class="p">.</span><span class="na">hadoop</span><span class="p">.</span><span class="na">hbase</span><span class="p">.</span><span class="na">regionserver</span><span class="p">.</span><span class="na">BloomType</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span>
      <span class="n">descriptor</span><span class="p">.</span><span class="na">getBloomType</span><span class="p">().</span><span class="na">name</span><span class="p">()));</span>
    <span class="k">for</span> <span class="p">(</span><span class="n">Map</span><span class="p">.</span><span class="na">Entry</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">property</span> <span class="p">:</span> <span class="n">descriptor</span><span class="p">.</span><span class="na">getProperties</span><span class="p">().</span><span class="na">entrySet</span><span class="p">())</span> <span class="p">{</span>
      <span class="n">hFamily</span><span class="p">.</span><span class="na">setValue</span><span class="p">(</span><span class="n">property</span><span class="p">.</span><span class="na">getKey</span><span class="p">(),</span> <span class="n">property</span><span class="p">.</span><span class="na">getValue</span><span class="p">());</span>
    <span class="p">}</span>
    <span class="n">LOG</span><span class="p">.</span><span class="na">info</span><span class="p">(</span><span class="s">&quot;Setting replication scope to global for ns {}, table {}, cf {}&quot;</span><span class="p">,</span> <span class="n">ns</span><span class="p">,</span> <span class="n">tableName</span><span class="p">,</span> <span class="n">descriptor</span><span class="p">.</span><span class="na">getName</span><span class="p">());</span>
    <span class="n">hFamily</span><span class="p">.</span><span class="na">setScope</span><span class="p">(</span><span class="n">HConstants</span><span class="p">.</span><span class="na">REPLICATION_SCOPE_GLOBAL</span><span class="p">);</span>
    <span class="k">return</span> <span class="n">hFamily</span><span class="p">;</span>
  <span class="p">}</span>

  <span class="cm">/**</span>
<span class="cm">   * Converts the {@link TableDescriptor} into corresponding {@link HTableDescriptor} for admin operations.</span>
<span class="cm">   * @param descriptor the table descriptor instance</span>
<span class="cm">   * @return the instance of HTableDescriptor</span>
<span class="cm">   */</span>
  <span class="kd">private</span> <span class="kd">static</span> <span class="n">HTableDescriptor</span> <span class="nf">getHTableDescriptor</span><span class="p">(</span><span class="n">TableDescriptor</span> <span class="n">descriptor</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">TableName</span> <span class="n">tableName</span> <span class="o">=</span> <span class="n">TableName</span><span class="p">.</span><span class="na">valueOf</span><span class="p">(</span><span class="n">descriptor</span><span class="p">.</span><span class="na">getNamespace</span><span class="p">(),</span> <span class="n">descriptor</span><span class="p">.</span><span class="na">getName</span><span class="p">());</span>
    <span class="n">HTableDescriptor</span> <span class="n">htd</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HTableDescriptor</span><span class="p">(</span><span class="n">tableName</span><span class="p">);</span>
    <span class="k">for</span> <span class="p">(</span><span class="n">Map</span><span class="p">.</span><span class="na">Entry</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">ColumnFamilyDescriptor</span><span class="o">&gt;</span> <span class="n">family</span> <span class="p">:</span> <span class="n">descriptor</span><span class="p">.</span><span class="na">getFamilies</span><span class="p">().</span><span class="na">entrySet</span><span class="p">())</span> <span class="p">{</span>
      <span class="n">htd</span><span class="p">.</span><span class="na">addFamily</span><span class="p">(</span><span class="n">getHColumnDesciptor</span><span class="p">(</span><span class="n">descriptor</span><span class="p">.</span><span class="na">getNamespace</span><span class="p">(),</span> <span class="n">descriptor</span><span class="p">.</span><span class="na">getName</span><span class="p">(),</span> <span class="n">family</span><span class="p">.</span><span class="na">getValue</span><span class="p">()));</span>
    <span class="p">}</span>

    <span class="k">for</span> <span class="p">(</span><span class="n">Map</span><span class="p">.</span><span class="na">Entry</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">CoprocessorDescriptor</span><span class="o">&gt;</span> <span class="n">coprocessor</span> <span class="p">:</span> <span class="n">descriptor</span><span class="p">.</span><span class="na">getCoprocessors</span><span class="p">().</span><span class="na">entrySet</span><span class="p">())</span> <span class="p">{</span>
      <span class="n">CoprocessorDescriptor</span> <span class="n">cpd</span> <span class="o">=</span> <span class="n">coprocessor</span><span class="p">.</span><span class="na">getValue</span><span class="p">();</span>
      <span class="k">try</span> <span class="p">{</span>
        <span class="n">htd</span><span class="p">.</span><span class="na">addCoprocessor</span><span class="p">(</span><span class="n">cpd</span><span class="p">.</span><span class="na">getClassName</span><span class="p">(),</span> <span class="k">new</span> <span class="n">Path</span><span class="p">(</span><span class="n">cpd</span><span class="p">.</span><span class="na">getPath</span><span class="p">()),</span> <span class="n">cpd</span><span class="p">.</span><span class="na">getPriority</span><span class="p">(),</span> <span class="n">cpd</span><span class="p">.</span><span class="na">getProperties</span><span class="p">());</span>
      <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">IOException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">LOG</span><span class="p">.</span><span class="na">error</span><span class="p">(</span><span class="s">&quot;Error adding coprocessor.&quot;</span><span class="p">,</span> <span class="n">e</span><span class="p">);</span>
      <span class="p">}</span>
    <span class="p">}</span>

    <span class="k">for</span> <span class="p">(</span><span class="n">Map</span><span class="p">.</span><span class="na">Entry</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">property</span> <span class="p">:</span> <span class="n">descriptor</span><span class="p">.</span><span class="na">getProperties</span><span class="p">().</span><span class="na">entrySet</span><span class="p">())</span> <span class="p">{</span>
      <span class="n">htd</span><span class="p">.</span><span class="na">setValue</span><span class="p">(</span><span class="n">property</span><span class="p">.</span><span class="na">getKey</span><span class="p">(),</span> <span class="n">property</span><span class="p">.</span><span class="na">getValue</span><span class="p">());</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="n">htd</span><span class="p">;</span>
  <span class="p">}</span>

  <span class="cm">/**</span>
<span class="cm">   * Generate the peer configuration which is used to perform DDL operations on the remote cluster using Admin</span>
<span class="cm">   * @param context instance of {@link HBaseDDLExecutorContext} with which the DDL executor is initialized</span>
<span class="cm">   * @return the {@link Configuration} to be used for DDL operations on the remote cluster</span>
<span class="cm">   */</span>
  <span class="kd">private</span> <span class="kd">static</span> <span class="n">Configuration</span> <span class="nf">generatePeerConfig</span><span class="p">(</span><span class="n">HBaseDDLExecutorContext</span> <span class="n">context</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">Configuration</span> <span class="n">peerConf</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Configuration</span><span class="p">();</span>
    <span class="n">peerConf</span><span class="p">.</span><span class="na">clear</span><span class="p">();</span>

    <span class="k">for</span> <span class="p">(</span><span class="n">Map</span><span class="p">.</span><span class="na">Entry</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">entry</span> <span class="p">:</span> <span class="n">context</span><span class="p">.</span><span class="na">getProperties</span><span class="p">().</span><span class="na">entrySet</span><span class="p">())</span> <span class="p">{</span>
      <span class="n">peerConf</span><span class="p">.</span><span class="na">set</span><span class="p">(</span><span class="n">entry</span><span class="p">.</span><span class="na">getKey</span><span class="p">(),</span> <span class="n">entry</span><span class="p">.</span><span class="na">getValue</span><span class="p">());</span>
    <span class="p">}</span>

    <span class="n">StringWriter</span> <span class="n">sw</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StringWriter</span><span class="p">();</span>
    <span class="k">try</span> <span class="p">{</span>
      <span class="n">Configuration</span><span class="p">.</span><span class="na">dumpConfiguration</span><span class="p">(</span><span class="n">peerConf</span><span class="p">,</span> <span class="n">sw</span><span class="p">);</span>
      <span class="n">LOG</span><span class="p">.</span><span class="na">debug</span><span class="p">(</span><span class="s">&quot;PeerConfig - {}&quot;</span><span class="p">,</span> <span class="n">sw</span><span class="p">);</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">IOException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">LOG</span><span class="p">.</span><span class="na">error</span><span class="p">(</span><span class="s">&quot;Error dumping config.&quot;</span><span class="p">,</span> <span class="n">e</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="n">peerConf</span><span class="p">;</span>
  <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="pom-file">
<h2>POM File<a class="headerlink" href="#pom-file" title="Permalink to this headline">🔗</a></h2>
<p>Corresponding <code class="docutils literal notranslate"><span class="pre">pom.xml</span></code>. Configure the property <code class="docutils literal notranslate"><span class="pre">hbase-client</span></code> (currently <code class="docutils literal notranslate"><span class="pre">1.0.0-cdh5.5.1</span></code>) below as appropriate:</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="n">xml</span> <span class="n">version</span><span class="o">=</span><span class="s">&quot;1.0&quot;</span> <span class="n">encoding</span><span class="o">=</span><span class="s">&quot;UTF-8&quot;</span><span class="o">?&gt;</span>
<span class="o">&lt;</span><span class="n">project</span> <span class="n">xmlns</span><span class="o">=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0&quot;</span>
         <span class="n">xmlns</span><span class="p">:</span><span class="n">xsi</span><span class="o">=</span><span class="s">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
         <span class="n">xsi</span><span class="p">:</span><span class="n">schemaLocation</span><span class="o">=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;</span><span class="o">&gt;</span>
  <span class="o">&lt;</span><span class="n">modelVersion</span><span class="o">&gt;</span><span class="mf">4.0.0</span><span class="o">&lt;/</span><span class="n">modelVersion</span><span class="o">&gt;</span>

  <span class="o">&lt;</span><span class="n">groupId</span><span class="o">&gt;</span><span class="n">io</span><span class="p">.</span><span class="na">cdap</span><span class="p">.</span><span class="na">cdap</span><span class="o">&lt;/</span><span class="n">groupId</span><span class="o">&gt;</span>
  <span class="o">&lt;</span><span class="n">artifactId</span><span class="o">&gt;</span><span class="n">HBaseDDLExecutorExtension</span><span class="o">&lt;/</span><span class="n">artifactId</span><span class="o">&gt;</span>
  <span class="o">&lt;</span><span class="n">version</span><span class="o">&gt;</span><span class="mf">1.0</span><span class="o">-</span><span class="n">SNAPSHOT</span><span class="o">&lt;/</span><span class="n">version</span><span class="o">&gt;</span>

  <span class="o">&lt;</span><span class="n">name</span><span class="o">&gt;</span><span class="n">HBase</span> <span class="n">DDL</span> <span class="n">executor</span><span class="o">&lt;/</span><span class="n">name</span><span class="o">&gt;</span>
  <span class="o">&lt;</span><span class="n">properties</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">cdap</span><span class="p">.</span><span class="na">version</span><span class="o">&gt;|</span><span class="n">release</span><span class="o">|&lt;/</span><span class="n">cdap</span><span class="p">.</span><span class="na">version</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">slf4j</span><span class="p">.</span><span class="na">version</span><span class="o">&gt;</span><span class="mf">1.7.5</span><span class="o">&lt;/</span><span class="n">slf4j</span><span class="p">.</span><span class="na">version</span><span class="o">&gt;</span>
  <span class="o">&lt;/</span><span class="n">properties</span><span class="o">&gt;</span>

  <span class="o">&lt;</span><span class="n">repositories</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">repository</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">id</span><span class="o">&gt;</span><span class="n">sonatype</span><span class="o">&lt;/</span><span class="n">id</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">url</span><span class="o">&gt;</span><span class="n">https</span><span class="p">:</span><span class="c1">//oss.sonatype.org/content/groups/public&lt;/url&gt;</span>
    <span class="o">&lt;/</span><span class="n">repository</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">repository</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">id</span><span class="o">&gt;</span><span class="n">apache</span><span class="p">.</span><span class="na">snapshots</span><span class="o">&lt;/</span><span class="n">id</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">url</span><span class="o">&gt;</span><span class="n">https</span><span class="p">:</span><span class="c1">//repository.apache.org/content/repositories/snapshots&lt;/url&gt;</span>
    <span class="o">&lt;/</span><span class="n">repository</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">repository</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">id</span><span class="o">&gt;</span><span class="n">cloudera</span><span class="o">&lt;/</span><span class="n">id</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">url</span><span class="o">&gt;</span><span class="n">https</span><span class="p">:</span><span class="c1">//repository.cloudera.com/artifactory/cloudera-repos/&lt;/url&gt;</span>
    <span class="o">&lt;/</span><span class="n">repository</span><span class="o">&gt;</span>
  <span class="o">&lt;/</span><span class="n">repositories</span><span class="o">&gt;</span>

  <span class="o">&lt;</span><span class="n">dependencies</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">dependency</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">groupId</span><span class="o">&gt;</span><span class="n">io</span><span class="p">.</span><span class="na">cdap</span><span class="p">.</span><span class="na">cdap</span><span class="o">&lt;/</span><span class="n">groupId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">artifactId</span><span class="o">&gt;</span><span class="n">cdap</span><span class="o">-</span><span class="n">hbase</span><span class="o">-</span><span class="n">spi</span><span class="o">&lt;/</span><span class="n">artifactId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">version</span><span class="o">&gt;</span><span class="n">$</span><span class="p">{</span><span class="n">cdap</span><span class="p">.</span><span class="na">version</span><span class="p">}</span><span class="o">&lt;/</span><span class="n">version</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">scope</span><span class="o">&gt;</span><span class="n">provided</span><span class="o">&lt;/</span><span class="n">scope</span><span class="o">&gt;</span>
    <span class="o">&lt;/</span><span class="n">dependency</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">dependency</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">groupId</span><span class="o">&gt;</span><span class="n">org</span><span class="p">.</span><span class="na">apache</span><span class="p">.</span><span class="na">hbase</span><span class="o">&lt;/</span><span class="n">groupId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">artifactId</span><span class="o">&gt;</span><span class="n">hbase</span><span class="o">-</span><span class="n">client</span><span class="o">&lt;/</span><span class="n">artifactId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">version</span><span class="o">&gt;</span><span class="mf">1.0.0</span><span class="o">-</span><span class="n">cdh5</span><span class="mf">.5.1</span><span class="o">&lt;/</span><span class="n">version</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">scope</span><span class="o">&gt;</span><span class="n">provided</span><span class="o">&lt;/</span><span class="n">scope</span><span class="o">&gt;</span>
    <span class="o">&lt;/</span><span class="n">dependency</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">dependency</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">groupId</span><span class="o">&gt;</span><span class="n">org</span><span class="p">.</span><span class="na">slf4j</span><span class="o">&lt;/</span><span class="n">groupId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">artifactId</span><span class="o">&gt;</span><span class="n">slf4j</span><span class="o">-</span><span class="n">api</span><span class="o">&lt;/</span><span class="n">artifactId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">version</span><span class="o">&gt;</span><span class="n">$</span><span class="p">{</span><span class="n">slf4j</span><span class="p">.</span><span class="na">version</span><span class="p">}</span><span class="o">&lt;/</span><span class="n">version</span><span class="o">&gt;</span>
    <span class="o">&lt;/</span><span class="n">dependency</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">dependency</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">groupId</span><span class="o">&gt;</span><span class="n">org</span><span class="p">.</span><span class="na">slf4j</span><span class="o">&lt;/</span><span class="n">groupId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">artifactId</span><span class="o">&gt;</span><span class="n">log4j</span><span class="o">-</span><span class="n">over</span><span class="o">-</span><span class="n">slf4j</span><span class="o">&lt;/</span><span class="n">artifactId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">version</span><span class="o">&gt;</span><span class="n">$</span><span class="p">{</span><span class="n">slf4j</span><span class="p">.</span><span class="na">version</span><span class="p">}</span><span class="o">&lt;/</span><span class="n">version</span><span class="o">&gt;</span>
    <span class="o">&lt;/</span><span class="n">dependency</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">dependency</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">groupId</span><span class="o">&gt;</span><span class="n">org</span><span class="p">.</span><span class="na">slf4j</span><span class="o">&lt;/</span><span class="n">groupId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">artifactId</span><span class="o">&gt;</span><span class="n">jcl</span><span class="o">-</span><span class="n">over</span><span class="o">-</span><span class="n">slf4j</span><span class="o">&lt;/</span><span class="n">artifactId</span><span class="o">&gt;</span>
      <span class="o">&lt;</span><span class="n">version</span><span class="o">&gt;</span><span class="n">$</span><span class="p">{</span><span class="n">slf4j</span><span class="p">.</span><span class="na">version</span><span class="p">}</span><span class="o">&lt;/</span><span class="n">version</span><span class="o">&gt;</span>
    <span class="o">&lt;/</span><span class="n">dependency</span><span class="o">&gt;</span>
  <span class="o">&lt;/</span><span class="n">dependencies</span><span class="o">&gt;</span>

<span class="o">&lt;/</span><span class="n">project</span><span class="o">&gt;</span>
</pre></div>
</div>
</div>
</div>

</div>
    <div class="col-md-2">
      <div id="right-sidebar" class="bs-sidenav scrollable-y" role="complementary">
        <div id="localtoc-scrollspy">
        </div>
      </div>
    </div></div>
</div>
<!-- block main content end -->
<!-- block footer -->
<footer class="footer">
      <div class="container">
        <div class="row">
          <div class="col-md-2 footer-left"><a title="Appendix: Minimal cdap-site.xml" href="minimal-cdap-site.html" />Previous</a></div>
          <div class="col-md-8 footer-center"><a class="footer-tab-link" href="../table-of-contents/../../reference-manual/licenses/index.html">Copyright</a> &copy; 2014-2020 Cask Data, Inc.&bull; <a class="footer-tab-link" href="//docs.cask.co/cdap/6.1.1/cdap-docs-6.1.1-web.zip" rel="nofollow">Download</a> an archive or
<a class="footer-tab-link" href="//docs.cask.co/cdap">switch the version</a> of the documentation
          </div>
          <div class="col-md-2 footer-right">&mdash;</div>
        </div>
      </div>
    </footer>
<!-- block footer end -->
<script type="text/javascript" src="../_static/bootstrap-3.3.6/js/bootstrap.min.js"></script><script type="text/javascript" src="../_static/js/bootstrap-sphinx.js"></script><script type="text/javascript" src="../_static/js/abixTreeList-2.js"></script><script type="text/javascript" src="../_static/js/cdap-dynamicscrollspy-4.js"></script><script type="text/javascript" src="../_static/js/cdap-version-menu.js"></script><script type="text/javascript" src="../_static/js/copy-to-clipboard.js"></script><script type="text/javascript" src="../_static/js/jquery.mousewheel.min.js"></script><script type="text/javascript" src="../_static/js/jquery.mCustomScrollbar.js"></script><script type="text/javascript" src="../_static/js/js.cookie.js"></script><script type="text/javascript" src="../_static/js/tabbed-parsed-literal-0.2.js"></script><script type="text/javascript" src="../_static/js/cdap-onload-javascript.js"></script><script type="text/javascript" src="../_static/js/cdap-version-menu.js"></script>
    <script src="https://cdap.gitee.io/docs/cdap/json-versions.js"/></script>
  </body>
</html>